<template>
  <view class="store-detail-box">
    <u-swiper
      :list="picArr"
      :autoplay="false"
      height="250"
      circular
      indicator
      imgMode="aspectFill"
    ></u-swiper>
    <view class="title-box">
      <view class="title">{{ storeObj.merchantName }}</view>
      <view class="rate">
        <u-rate
          :count="5"
          :gutter="0"
          active-color="#f39d21"
          inactive-color="#b2b2b2"
          readonly
          :value="score"
        ></u-rate>
        <text class="score"
          >评分：{{ (score && Number(score).toFixed(1)) || 0 }}</text
        >
      </view>
      <view class="m-top2" @click="clickFun"
        ><u-icon name="map" size="16"></u-icon
        >{{ storeObj.merchantAddress }}</view
      >
    </view>
  </view>
</template>

<script>
import {
  getStoreData,
  setStoreData,
  httpPost,
  httpGet,
  formatDistance,
  formatStr,
  bdMapToTxMap,
  txMapToBdMap,
} from "@/utils/http.js";
const avatar = require(`@/img/my/avatar1.jpg`);
const app = getApp();
const globalData = app.globalData;
const wxImg = globalData.wxImg;
export default {
  data() {
    return {
      storeObj: {},
      picArr: [],
      score: "",
    };
  },
  onLoad(options) {
    if (options.id) {
      this.score = options.score;
      this.getdataFun(options.id);
    }
  },
  methods: {
    clickFun() {
      wx.openLocation({
        ...bdMapToTxMap(this.storeObj.longitude, this.storeObj.latitude),
        scale: 15,
        name: this.storeObj.name,
        address: this.storeObj.merchantAddress,
      });
    },
    getdataFun(id) {
      const _this = this;
      httpGet("/api/sellerstore/applyInfo/" + id)
        .then((res) => {
          const result = res.data;
          _this.storeObj = result;
          _this.picArr = [];
          if (result.imgLogo) {
            _this.picArr.push(wxImg + result.imgLogo);
          }
          if (result.imgIndoor) {
            _this.picArr.push(wxImg + result.imgIndoor);
          }
        })
        .catch((e) => {
          _this.storeObj = {};
          _this.picArr = [];
        });
    },
  },
};
</script>

<style lang="scss">
.store-detail-box {
  width: 100vw;
  min-height: 100vh;
  background: #f8f8f8;
  .title-box {
    padding: 12px 16px 24px;
    font-size: 14px;
    background: #fff;
    .rate {
      display: flex;
      align-items: center;
      color: #f39d21;
      .score {
        margin-left: 3px;
      }
    }
    .m-top2 {
      color: #666;
      font-size: 14px;
      margin-top: 32px;
      display: flex;
      align-items: flex-start;
      /deep/.u-icon__icon {
        margin: 2px 6px 0 0;
      }
    }
    .title {
      font-size: 18px;
      font-weight: bold;
      margin-bottom: 4px;
      color: #333;
    }
  }
}
</style>
